package com.heng.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heng.constants.CouponStatusEnum;
import com.heng.dao.entity.Coupon;
import com.heng.dao.mapper.CouponMapper;
import com.heng.service.CouponService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

// 优惠券Service实现
@Service
@Transactional
public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> implements CouponService {

    @Override
    public Coupon getValidCouponById(Long couponId) {
        // 查询状态为有效、在有效期内、库存>0的优惠券
        return baseMapper.selectValidCouponById(couponId, CouponStatusEnum.VALID.getCode());
    }
}
